<?php

namespace App\Models\Trip\TripOrderCosts;

use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
 * App\Models\Trip\TripOrderCosts\TripOrderPassengerCosts
 *
 * @property int         $id
 * @property string      $user_id      用户id
 * @property string      $trip_id      行程业务id
 * @property int         $trip_type    出行类型 1火车 2飞机 3 酒店
 * @property string      $order_sn     订单单号
 * @property string      $passenger_id 订单单号
 * @property int         $type         如:车票,保险费,人工出票,维语用语言包,提示信息写到配置文件
 * @property string      $price        费用单价
 * @property string      $name         收费项如 疫情隔离补贴,指定车厢.指定铺席,维语用语言包
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 * @property int         $sequence
 * @property string|null $detail       如 二等座，险种，指定的铺席坐席内容等
 * @method static Builder|TripOrderPassengerCost newModelQuery()
 * @method static Builder|TripOrderPassengerCost newQuery()
 * @method static Builder|TripOrderPassengerCost query()
 * @method static Builder|TripOrderPassengerCost whereCreatedAt($value)
 * @method static Builder|TripOrderPassengerCost whereDetail($value)
 * @method static Builder|TripOrderPassengerCost whereId($value)
 * @method static Builder|TripOrderPassengerCost whereName($value)
 * @method static Builder|TripOrderPassengerCost whereOrderSn($value)
 * @method static Builder|TripOrderPassengerCost wherePassengerId($value)
 * @method static Builder|TripOrderPassengerCost wherePrice($value)
 * @method static Builder|TripOrderPassengerCost whereSequence($value)
 * @method static Builder|TripOrderPassengerCost whereTripId($value)
 * @method static Builder|TripOrderPassengerCost whereTripType($value)
 * @method static Builder|TripOrderPassengerCost whereType($value)
 * @method static Builder|TripOrderPassengerCost whereUpdatedAt($value)
 * @method static Builder|TripOrderPassengerCost whereUserId($value)
 * @property string $pay_sn 支付单号
 * @property int $parent_type 父类型 可能与子类型一致
 * @method static Builder|TripOrderPassengerCost whereParentType($value)
 * @method static Builder|TripOrderPassengerCost wherePaySn($value)
 * @property int|null $confirm_state 价格确认状态 1 已确认 0 待确认
 * @method static Builder|TripOrderPassengerCost whereConfirmState($value)
 * @mixin Eloquent
 */
class TripOrderPassengerCost extends Model
{
    use HasFactory;

    protected $table = 'trip_order_passenger_costs';
    protected $fillable
                     = [
            'user_id',
            'trip_id',
            'trip_type',
            'order_sn',
            'pay_sn', // 按乘客退款时有必要
            'passenger_id',
            'sequence',
            'type',        // 细节类型
            'parent_type', // 父类型 比如编辑的票价差额属于 票价 , 当发生退票价差价时  需要按比例计算
            'price',
            'name',
            'detail',
            'confirm_state',
        ];

    /**
     * @return float
     */
    public function getPrice(): float
    {
        return $this->getAttribute('price');
    }

    public function getType(): int
    {
        return $this->getAttribute('type');
    }

    public function getConfirmState(): int
    {
        return $this->getAttribute('confirm_state');
    }

    public function getPaySn(): string
    {
        return $this->getAttribute('pay_sn');
    }
}
